#include "cameradialog.h"
#include "ui_cameradialog.h"

CameraDialog::CameraDialog(QWidget *parent)
    : QDialog(parent)
    , m_pCameraInfo(nullptr)
    , ui(new Ui::CameraDialog)
{
    ui->setupUi(this);
}

CameraDialog::~CameraDialog()
{
    delete ui;
}

void CameraDialog::SetCameraInfo(CameraInfo* pCameraInfo){
    m_pCameraInfo = pCameraInfo;
    ui->lineEditIPAddress->setText(pCameraInfo->GetIPAddress());
    ui->lineEditMACAddress->setText(pCameraInfo->GetMACAddress());
    ui->lineEditName->setText(pCameraInfo->GetName());
    ui->lineEditImageNumbers->setText(pCameraInfo->GetCameraIdentifiers());
}

void CameraDialog::accept(){
    m_pCameraInfo->SetIPAddress(ui->lineEditIPAddress->text());
    m_pCameraInfo->SetMACAddress(ui->lineEditMACAddress->text());
    m_pCameraInfo->SetName(ui->lineEditName->text());
    m_pCameraInfo->SetCameraIdentifiers(ui->lineEditImageNumbers->text());

    QDialog::accept();
}
